package com.adrian.controller;

import com.adrian.pojo.Product;
import com.adrian.pojo.Type;
import com.adrian.service.ProductTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Auther: Adrian
 * @Date: 2020/3/22 10:32
 * @Description:
 */
@RestController
public class ProductTypeController {

    @Autowired
    private ProductTypeService productTypeService;


    @RequestMapping("/addType")
    public int addType(@RequestBody Type type){
       return productTypeService.addType(type);
    }

    /**
     * 根据ID查询对象
     * @param id
     * @return
     */
    @RequestMapping("/type_getById")
    public Type getTypeById(@RequestParam int id){
        return productTypeService.getById(id);
    }

    /**
     * 根据ID删除
     * @param id
     * @return
     */
    @RequestMapping("/type_delete")
    public int deleteType(@RequestParam int id){
        return productTypeService.deleteType(id);
    }

    /**
     * 根据ID更新
     * @param type
     * @return
     */
    @RequestMapping("/type_updatebyId")
    public int updateType(@RequestBody Type type){
        return productTypeService.updateType(type);
    }
}
